//记录飞机、子弹的相关数据
#include<stdlib.h>
#include<assert.h>

//敌机类型
enum EnemyType { NORMAL, FAST, HEAVY, BONUS };

//游戏状态
enum GameState { MENU, PLAYING, PAUSED, GAMEOVER };

//道具类型
enum ItemType { HEALTH, POWERUP, SHIELD, BOMB };


//链表节点的结构体（我方飞机、敌方飞机、子弹的类型）
typedef struct NODE {
	int x;
	int y;
	int speed;//移动速度
	int health;//生命值
	int type;//敌机类型
	struct NODE* next;//指针，指向下一个节点

}Node;


//粒子结构
typedef struct PARTICLE {

	int x, y;
	int vx, vy;
	int life;
	int size;
	COLORREF color;
}Particle;


//敌机类型

typedef struct ITEM {
	int x, y;
	ItemType type;
	int speed;
}Item;

//Star
typedef struct STAR {
	int x, y;
	int speed;
	int brightness;
}Star;


//链表结构的结点
typedef struct LinkList
{
	struct NODE* head;
	struct NODE* end;
}LL;

//创建链表结点函数
Node* Node_init(int x,int y,int speed, int type = NORMAL, int health = 1)
{
	Node* temp = (Node*)malloc(sizeof(Node));
	
	temp->x = x;
	temp->y = y;
	temp->speed = speed;
	temp->type = type;
	temp->health = health;
	temp->next = NULL;
	return temp;
}

//单链表结点插入函数,尾插法
void LinkList_insert(LL*list,Node*node)
{
	if (list == NULL)
	{
		return;
	}
	if (list->head == NULL)
	{
		list->head = list->end = node;
	}
	else {
		list->end->next = node;
		list->end = node;
	}
}

//单链表结点的删除
void Node_delete(LL* list, Node* p)//p指向要删除的结点
{
	if (list == NULL || list->head==NULL)
	{
		return;
	}
	if (p == list->head)
	{
		list->head = p->next;
		if (p == list->end)list->end = NULL;
		free(p);
		return;
	}
	Node* temp = list->head;
	while (temp != NULL && temp->next != p) {
		temp = temp->next;
	}

	if (temp != NULL) {
		temp->next = p->next;
		if (p == list->end) list->end = temp;
		free(p);
	}
}

//整个单链表结点的释放
void LinkList_All(LL* list)
{
	if (list == NULL || list->head == NULL)
	{
		return;
	}
	//删除单链表结点
	for (Node* temp1 = list->head; temp1 != NULL;)
	{
		Node* temp2 = temp1;
		temp1 = temp1->next;
		free(temp2);
	}
	list->head = list->end = NULL;
	
}